using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class LIST_PRIControl
    {
		#region Local Variable
        private LIST_PRIDataAccess _objDAO;
		#endregion Local Variable
		
		#region Method
        public LIST_PRIControl()
        {
            _objDAO = new LIST_PRIDataAccess();
        }
		
        public LIST_PRIInfo Get(
        String DTB,
        String P01,
        String P02,
        String P03,
        String P04,
        String P05,
        String P06,
		ref string sErr)
        {
            return _objDAO.Get(
            DTB,
            P01,
            P02,
            P03,
            P04,
            P05,
            P06,
			ref sErr);
        }
		
        public DataTable GetAll(
        String DTB,
        ref string sErr)
        {
            return _objDAO.GetAll(
            DTB,
            ref sErr);
        }
		
        public Int32 Add(LIST_PRIInfo obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }
		
        public string Update(LIST_PRIInfo obj)
        {
            return _objDAO.Update(obj);
        }
		
        public string Delete(
        String DTB,
        String P01,
        String P02,
        String P03,
        String P04,
        String P05,
        String P06
		)
        {
            return _objDAO.Delete(
            DTB,
            P01,
            P02,
            P03,
            P04,
            P05,
            P06
			);
        }  
        public Boolean IsExist(
        String DTB,
        String P01,
        String P02,
        String P03,
        String P04,
        String P05,
        String P06
		)
        {
            return _objDAO.IsExist(
            DTB,
            P01,
            P02,
            P03,
            P04,
            P05,
            P06
			);
        } 
		
        public DataTable Search(String columnName, String columnValue, String condition, ref String sErr)
        {           
            return _objDAO.Search(columnName, columnValue, condition, "", ref  sErr);
        }
        public string InsertUpdate(LIST_PRIInfo obj)
        {
            string sErr = "";
            if (IsExist(
            obj.DTB,
            obj.P01,
            obj.P02,
            obj.P03,
            obj.P04,
            obj.P05,
            obj.P06
			))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }
		
        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
			LIST_PRIInfo inf = new LIST_PRIInfo();
            return inf.ToDataTable();
        }
		
		public string TransferIn(DataRow row)
        {
            LIST_PRIInfo inf = new LIST_PRIInfo(row);
            return InsertUpdate(inf);
        }
		#endregion Method


        public DTO.LIST_PRIInfo GetByPos(string db,int _currentIndex, ref string sErr)
        {
            return _objDAO.GetByPos(db,_currentIndex, ref sErr);
        }

        public int GetCountRecord(string db,ref string sErr)
        {
            return _objDAO.GetCountRecord(db, ref sErr);
        }
    }
}
